﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace Iworld.Toolkit.Converter
{
    public class BoolToVisibilityConverter : ConverterBase<bool?, Visibility>
    {
        protected override Visibility ConvertNotNull(bool? value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (parameter != null && (parameter.ToString() == "reverse" || parameter.ToString() == "反转"))
            {
                return value == false ? Visibility.Visible : Visibility.Collapsed;
            }
            return value == true ? Visibility.Visible : Visibility.Collapsed;
        }

        protected override bool? ConvertBackNotNull(Visibility value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (parameter != null && parameter.ToString() == "reverse" || parameter.ToString() == "反转")
            {
                return value == Visibility.Collapsed ? true : false;
            }
            return value == Visibility.Visible ? true : false;
        }

    }
}
